<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<script>
   /* setTimeout(function () {
        console.log(1);
    },1000);
   var time= setInterval(function () {
        console.log(2);
    },1000);
    setTimeout(function () {
       clearInterval(time)
    },3000);*/

    setInterval(function () {
        var spanEle=document.getElementById('s');
        console.log(spanEle);
        var val=spanEle.innerHTML;
        console.log(val);
        if(val==1){
            location.href='http://www.baidu.com'
            return;
        }
       spanEle.innerHTML=val-1;
    },1000)

</script>
<span id="s">5</span>
</body>
</html>